package blue.txt.model;

import org.apache.commons.lang3.StringUtils;

public class FileModel
{
	private int index; // 序号，用于排序
	private Integer chapter; // 章
	private Integer section; // 节
	private String title; // 标题
	private StringBuilder content = new StringBuilder(); // 内容

	public FileModel()
	{
	}

	public void printFileName()
	{
		String filename = this.getFileName();
		System.out.println(filename);
	}

	public String getFileName()
	{
		StringBuilder name = new StringBuilder(32);
		name.append(StringUtils.leftPad(String.valueOf(index), 4, '0')).append("_");
		
		if (chapter != null)
			name.append("第").append(chapter).append("章_");
		if (section != null)
			name.append("第").append(section).append("节_");
			
		name.append(title).append(".txt");
		return name.toString();
	}

	public void setIndex(int index)
	{
		this.index = index;
	}

	public Integer getChapter()
	{
		return chapter;
	}

	public void setChapter(Integer chapter)
	{
		this.chapter = chapter;
	}

	public Integer getSection()
	{
		return section;
	}

	public void setSection(Integer section)
	{
		this.section = section;
	}

	public String getTitle()
	{
		return title;
	}

	public void setTitle(String title)
	{
		this.title = title;
	}

	public StringBuilder getContent()
	{
		return content;
	}

	public void add(String content)
	{
		this.content.append(content);
	}

}
